<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>if..else语句</title>        
        <script>       
          //0为星期日,依次类推
          var dayOfWeek = 3;
          switch(dayOfWeek){
              case 0:                
                  console.log('星期日');
                  break;
              case 1:
                  console.log('星期一');                
                  break;
              case 2:
                  console.log('星期二');
                  break;
              case 3:
                  console.log('星期三');
                  break;
              case 4:
                  console.log('星期四');
                  break;
              case 5:
                  console.log('星期五');
                  break;
              case 6:
                  console.log('星期六'); 
                  break;
          }
          //等价于
          var dayOfWeek = 3;
          if (dayOfWeek === 0) {
            console.log('星期日');
          } else if(dayOfWeek === 1){
            console.log('星期一');
          } else if(dayOfWeek === 2){
            console.log('星期二');
          } else if (dayOfWeek === 3) {
            console.log('星期三');
          } else if (dayOfWeek === 4) {
            console.log('星期四');
          } else if (dayOfWeek === 5) {
            console.log('星期五');
          } else if (dayOfWeek === 6) {
            console.log('星期六');
          }
        </script>
    </head>
    <body>
    </body>
</html>



